﻿using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;

namespace Web.Step02
{
   public partial class Default : AppPage
   {
      protected void Page_Load(object sender, EventArgs e)
      {
         if (IsPostBack) return;

         using (var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["TheDatabaseConnectionString"].ConnectionString))
         using (var cmd = new SqlCommand("SELECT * FROM Product", conn))
         {
            conn.Open();

            dg.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            dg.DataBind();
         }
      }
   }
}